package com.sicheng.lc.周赛.分类.模拟;

/**
 * @author zsc
 * @version 1.0
 * @date 2022/6/14 11:42
 */
public class 强密码检验器 {
    //    https://leetcode.cn/problems/strong-password-checker-ii/
    public boolean strongPasswordCheckerII(String password) {
        if (password.length() < 8)
            return false;
        int[] limit = new int[4];
        String s = "!@#$%^&*()-+";
        char last = ' ';
        for (int i = 0; i < password.length(); i++) {
            char ch = password.charAt(i);
            if (ch == last) {
                return false;
            }

            if (ch >= '0' && ch <= '9') {
                limit[2]++;
            } else if (ch >= 'a' && ch <= 'z') {
                limit[1]++;
            } else if (ch >= 'A' && ch <= 'Z') {
                limit[0]++;
            } else if (limit[3] == 0) {
                limit[3]++;
            }
            last = ch;
        }
        boolean f = true;
        for (int j : limit) {
            f &= j > 0;
        }

        return f;
    }
}

